<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- saved from url=(0028)http://jdbi.org/archive.html -->
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></meta>


<title>abacus-common</title>

<script type="text/javascript" src="./css/ga.js"></script>
<script type="text/javascript">
	if (top.location != self.location)
		top.location.replace(self.location);
</script>

<link href="./css/css" rel="stylesheet" type="text/css"></link>
<link href="./css/css(1)" rel="stylesheet" type="text/css"></link>
<link rel="stylesheet" href="./css/syntax.css" type="text/css"></link>
<link rel="stylesheet" href="./css/screen.css" type="text/css"></link>

<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-65247258-1', 'auto');
  ga('send', 'pageview');
</script>

</head>
<body>
	<div id="site">
		<h1>
			<a href="./index.html">abacus-common</a> <span id="navigation"> <a href="./docs.html">Docs</a> | <a href="./download.html">Download</a>
				| <a href="./api-docs/index.html">Javadoc</a> | <a href="./faq.html">FAQ</a> | <a href="./community.html">Community</a>
			</span>
		</h1>
	</div>
	<!--
	<p><center><i>(Imagination is more important than knowledge --- Albert Einstein)</i></center></p>
	 -->
	<!-- 
	<p><center><i>(It is better to have 100 functions operate on one data structure than 10 functions on 10 data structures --- Alan Perlis)</i></center></p>
 	-->
	<div id="content">

		<div id="page">

			<h1>N</h1>
			<p>
				The initial purpose to create <a href="./api-docs/com/landawn/abacus/util/N.html">N</a> is to make java daily programming as easy/simple as possible.
				It provides a lot of most daily used methods for Primitive types/Array/String/Collection/Map/Entity and a more comfortable way to write code in Java. 
				Here is the <a href="./N.gif">panoramic view</a>(Move mouse to the left of your browser to enlarge the image). Try it, like it :-)...
			</p>

			<li><b>as...</b></li>
<!-- HTML generated using hilite.me --><div style="background: #f8f8f8; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%">String<span style="color: #666666">[]</span> strs <span style="color: #666666">=</span> N<span style="color: #666666">.</span><span style="color: #7D9029">asArray</span><span style="color: #666666">(</span><span style="color: #BA2121">&quot;a&quot;</span><span style="color: #666666">,</span> <span style="color: #BA2121">&quot;b&quot;</span><span style="color: #666666">,</span> <span style="color: #BA2121">&quot;c&quot;</span><span style="color: #666666">);</span>
N<span style="color: #666666">.</span><span style="color: #7D9029">println</span><span style="color: #666666">(</span>strs<span style="color: #666666">);</span>

List<span style="color: #666666">&lt;</span>String<span style="color: #666666">&gt;</span> list <span style="color: #666666">=</span> N<span style="color: #666666">.</span><span style="color: #7D9029">asList</span><span style="color: #666666">(</span><span style="color: #BA2121">&quot;a&quot;</span><span style="color: #666666">,</span> <span style="color: #BA2121">&quot;b&quot;</span><span style="color: #666666">,</span> <span style="color: #BA2121">&quot;c&quot;</span><span style="color: #666666">);</span>
N<span style="color: #666666">.</span><span style="color: #7D9029">println</span><span style="color: #666666">(</span>list<span style="color: #666666">);</span>

Set<span style="color: #666666">&lt;</span>String<span style="color: #666666">&gt;</span> set <span style="color: #666666">=</span> N<span style="color: #666666">.</span><span style="color: #7D9029">asSet</span><span style="color: #666666">(</span><span style="color: #BA2121">&quot;a&quot;</span><span style="color: #666666">,</span> <span style="color: #BA2121">&quot;b&quot;</span><span style="color: #666666">,</span> <span style="color: #BA2121">&quot;c&quot;</span><span style="color: #666666">);</span>
N<span style="color: #666666">.</span><span style="color: #7D9029">println</span><span style="color: #666666">(</span>set<span style="color: #666666">);</span>

Map<span style="color: #666666">&lt;</span>String<span style="color: #666666">,</span> Integer<span style="color: #666666">&gt;</span> map <span style="color: #666666">=</span> N<span style="color: #666666">.</span><span style="color: #7D9029">asMap</span><span style="color: #666666">(</span><span style="color: #BA2121">&quot;a&quot;</span><span style="color: #666666">,</span> <span style="color: #666666">1,</span> <span style="color: #BA2121">&quot;b&quot;</span><span style="color: #666666">,</span> <span style="color: #666666">2,</span> <span style="color: #BA2121">&quot;c&quot;</span><span style="color: #666666">,</span> <span style="color: #666666">3);</span>
N<span style="color: #666666">.</span><span style="color: #7D9029">println</span><span style="color: #666666">(</span>map<span style="color: #666666">);</span>

List<span style="color: #666666">&lt;</span>String<span style="color: #666666">&gt;</span> unmodifiableList <span style="color: #666666">=</span> N<span style="color: #666666">.</span><span style="color: #7D9029">asUnmodifiableList</span><span style="color: #666666">(</span>list<span style="color: #666666">);</span>
N<span style="color: #666666">.</span><span style="color: #7D9029">println</span><span style="color: #666666">(</span>unmodifiableList<span style="color: #666666">);</span>

Map<span style="color: #666666">&lt;</span>String<span style="color: #666666">,</span> Integer<span style="color: #666666">&gt;</span> unmodifiableMap <span style="color: #666666">=</span> N<span style="color: #666666">.</span><span style="color: #7D9029">asUnmodifiableMap</span><span style="color: #666666">(</span>map<span style="color: #666666">);</span>
N<span style="color: #666666">.</span><span style="color: #7D9029">println</span><span style="color: #666666">(</span>unmodifiableMap<span style="color: #666666">);</span>
</pre></div>



			<p></p>
			<li><b>stringOf/valueOf...</b></li>
<!-- HTML generated using hilite.me --><div style="background: #f8f8f8; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%">Timestamp date <span style="color: #666666">=</span> N<span style="color: #666666">.</span><span style="color: #7D9029">currentTimestamp</span><span style="color: #666666">();</span>
String str <span style="color: #666666">=</span> N<span style="color: #666666">.</span><span style="color: #7D9029">stringOf</span><span style="color: #666666">(</span>date<span style="color: #666666">);</span>
Timestamp date2 <span style="color: #666666">=</span> N<span style="color: #666666">.</span><span style="color: #7D9029">valueOf</span><span style="color: #666666">(</span>Timestamp<span style="color: #666666">.</span><span style="color: #7D9029">class</span><span style="color: #666666">,</span> str<span style="color: #666666">);</span>
assertEquals<span style="color: #666666">(</span>date<span style="color: #666666">,</span> date2<span style="color: #666666">);</span>

str <span style="color: #666666">=</span> N<span style="color: #666666">.</span><span style="color: #7D9029">stringOf</span><span style="color: #666666">(</span>account<span style="color: #666666">);</span>
Account account2 <span style="color: #666666">=</span> N<span style="color: #666666">.</span><span style="color: #7D9029">valueOf</span><span style="color: #666666">(</span>Account<span style="color: #666666">.</span><span style="color: #7D9029">class</span><span style="color: #666666">,</span> str<span style="color: #666666">);</span>
N<span style="color: #666666">.</span><span style="color: #7D9029">println</span><span style="color: #666666">(</span>account2<span style="color: #666666">);</span>
assertEquals<span style="color: #666666">(</span>account<span style="color: #666666">,</span> account2<span style="color: #666666">);</span>
</pre></div>

		
			<p></p>
			<li><b>concat/join/split...</b></li>
<!-- HTML generated using hilite.me --><div style="background: #f8f8f8; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #B00040">char</span><span style="color: #666666">[]</span> a <span style="color: #666666">=</span> <span style="color: #666666">{</span> <span style="color: #BA2121">&#39;a&#39;</span><span style="color: #666666">,</span> <span style="color: #BA2121">&#39;b&#39;</span><span style="color: #666666">,</span> <span style="color: #BA2121">&#39;c&#39;</span> <span style="color: #666666">};</span>
<span style="color: #B00040">char</span><span style="color: #666666">[]</span> b <span style="color: #666666">=</span> <span style="color: #666666">{</span> <span style="color: #BA2121">&#39;d&#39;</span><span style="color: #666666">,</span> <span style="color: #BA2121">&#39;e&#39;</span><span style="color: #666666">,</span> <span style="color: #BA2121">&#39;f&#39;</span> <span style="color: #666666">};</span>
<span style="color: #B00040">char</span><span style="color: #666666">[]</span> c <span style="color: #666666">=</span> N<span style="color: #666666">.</span><span style="color: #7D9029">concat</span><span style="color: #666666">(</span>a<span style="color: #666666">,</span> b<span style="color: #666666">);</span>

String str <span style="color: #666666">=</span> N<span style="color: #666666">.</span><span style="color: #7D9029">join</span><span style="color: #666666">(</span>c<span style="color: #666666">);</span>
N<span style="color: #666666">.</span><span style="color: #7D9029">println</span><span style="color: #666666">(</span>str<span style="color: #666666">);</span>

<span style="color: #B00040">char</span><span style="color: #666666">[]</span> d <span style="color: #666666">=</span> N<span style="color: #666666">.</span><span style="color: #7D9029">string2Array</span><span style="color: #666666">(</span><span style="color: #B00040">char</span><span style="color: #666666">[].</span><span style="color: #7D9029">class</span><span style="color: #666666">,</span> str<span style="color: #666666">);</span>
assertTrue<span style="color: #666666">(</span>N<span style="color: #666666">.</span><span style="color: #7D9029">equals</span><span style="color: #666666">(</span>c<span style="color: #666666">,</span> d<span style="color: #666666">));</span>

List<span style="color: #666666">&lt;</span><span style="color: #B00040">char</span><span style="color: #666666">[]&gt;</span> partitions <span style="color: #666666">=</span> N<span style="color: #666666">.</span><span style="color: #7D9029">split</span><span style="color: #666666">(</span>a<span style="color: #666666">,</span> <span style="color: #666666">2);</span>
N<span style="color: #666666">.</span><span style="color: #7D9029">println</span><span style="color: #666666">(</span>partitions<span style="color: #666666">);</span>
</pre></div>

			<p></p>
			<li><b>fill/nCopies/reverse/rotate/shuffle/sum/avg/min/max/median...</b></li>
<!-- HTML generated using hilite.me --><div style="background: #f8f8f8; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #B00040">int</span><span style="color: #666666">[]</span> a <span style="color: #666666">=</span> N<span style="color: #666666">.</span><span style="color: #7D9029">nCopies</span><span style="color: #666666">(3,</span> <span style="color: #666666">10);</span>
N<span style="color: #666666">.</span><span style="color: #7D9029">println</span><span style="color: #666666">(</span>a<span style="color: #666666">);</span> <span style="color: #408080; font-style: italic">// [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]</span>

N<span style="color: #666666">.</span><span style="color: #7D9029">fill</span><span style="color: #666666">(</span>a<span style="color: #666666">,</span> <span style="color: #666666">0);</span>
N<span style="color: #666666">.</span><span style="color: #7D9029">println</span><span style="color: #666666">(</span>a<span style="color: #666666">);</span> <span style="color: #408080; font-style: italic">// [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]</span>

a <span style="color: #666666">=</span> Array<span style="color: #666666">.</span><span style="color: #7D9029">of</span><span style="color: #666666">(1,</span> <span style="color: #666666">2,</span> <span style="color: #666666">3,</span> <span style="color: #666666">4,</span> <span style="color: #666666">5,</span> <span style="color: #666666">6);</span>
N<span style="color: #666666">.</span><span style="color: #7D9029">reverse</span><span style="color: #666666">(</span>a<span style="color: #666666">);</span>
N<span style="color: #666666">.</span><span style="color: #7D9029">println</span><span style="color: #666666">(</span>a<span style="color: #666666">);</span> <span style="color: #408080; font-style: italic">// [6, 5, 4, 3, 2, 1]</span>

a <span style="color: #666666">=</span> Array<span style="color: #666666">.</span><span style="color: #7D9029">of</span><span style="color: #666666">(1,</span> <span style="color: #666666">2,</span> <span style="color: #666666">3,</span> <span style="color: #666666">4,</span> <span style="color: #666666">5,</span> <span style="color: #666666">6);</span>
N<span style="color: #666666">.</span><span style="color: #7D9029">rotate</span><span style="color: #666666">(</span>a<span style="color: #666666">,</span> <span style="color: #666666">2);</span>
N<span style="color: #666666">.</span><span style="color: #7D9029">println</span><span style="color: #666666">(</span>a<span style="color: #666666">);</span> <span style="color: #408080; font-style: italic">// [5, 6, 1, 2, 3, 4]</span>

a <span style="color: #666666">=</span> Array<span style="color: #666666">.</span><span style="color: #7D9029">of</span><span style="color: #666666">(1,</span> <span style="color: #666666">2,</span> <span style="color: #666666">3,</span> <span style="color: #666666">4,</span> <span style="color: #666666">5,</span> <span style="color: #666666">6);</span>
N<span style="color: #666666">.</span><span style="color: #7D9029">shuffle</span><span style="color: #666666">(</span>a<span style="color: #666666">);</span>
N<span style="color: #666666">.</span><span style="color: #7D9029">println</span><span style="color: #666666">(</span>a<span style="color: #666666">);</span> <span style="color: #408080; font-style: italic">// [5, 3, 1, 4, 6, 2]</span>

a <span style="color: #666666">=</span> Array<span style="color: #666666">.</span><span style="color: #7D9029">of</span><span style="color: #666666">(1,</span> <span style="color: #666666">2,</span> <span style="color: #666666">3,</span> <span style="color: #666666">4,</span> <span style="color: #666666">5,</span> <span style="color: #666666">6);</span>
N<span style="color: #666666">.</span><span style="color: #7D9029">println</span><span style="color: #666666">(</span>N<span style="color: #666666">.</span><span style="color: #7D9029">sum</span><span style="color: #666666">(</span>a<span style="color: #666666">));</span> <span style="color: #408080; font-style: italic">// 21</span>
N<span style="color: #666666">.</span><span style="color: #7D9029">println</span><span style="color: #666666">(</span>N<span style="color: #666666">.</span><span style="color: #7D9029">avg</span><span style="color: #666666">(</span>a<span style="color: #666666">));</span> <span style="color: #408080; font-style: italic">// 3.5</span>
N<span style="color: #666666">.</span><span style="color: #7D9029">println</span><span style="color: #666666">(</span>N<span style="color: #666666">.</span><span style="color: #7D9029">min</span><span style="color: #666666">(</span>a<span style="color: #666666">));</span> <span style="color: #408080; font-style: italic">// 1</span>
N<span style="color: #666666">.</span><span style="color: #7D9029">println</span><span style="color: #666666">(</span>N<span style="color: #666666">.</span><span style="color: #7D9029">max</span><span style="color: #666666">(</span>a<span style="color: #666666">));</span> <span style="color: #408080; font-style: italic">// 6</span>
N<span style="color: #666666">.</span><span style="color: #7D9029">println</span><span style="color: #666666">(</span>N<span style="color: #666666">.</span><span style="color: #7D9029">median</span><span style="color: #666666">(</span>a<span style="color: #666666">));</span> <span style="color: #408080; font-style: italic">// 3</span>
</pre></div>


			<p></p>
			<li><b>add/addAll/remove/removeAll/insert/insertAll/delete/deleteAll/replaceAll...</b></li>
<!-- HTML generated using hilite.me --><div style="background: #f8f8f8; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #B00040">int</span><span style="color: #666666">[]</span> a <span style="color: #666666">=</span> <span style="color: #666666">{</span> <span style="color: #666666">1,</span> <span style="color: #666666">2,</span> <span style="color: #666666">3,</span> <span style="color: #666666">4,</span> <span style="color: #666666">5,</span> <span style="color: #666666">6</span> <span style="color: #666666">};</span>
<span style="color: #B00040">int</span><span style="color: #666666">[]</span> b <span style="color: #666666">=</span> N<span style="color: #666666">.</span><span style="color: #7D9029">add</span><span style="color: #666666">(</span>a<span style="color: #666666">,</span> <span style="color: #666666">7);</span>
N<span style="color: #666666">.</span><span style="color: #7D9029">println</span><span style="color: #666666">(</span>b<span style="color: #666666">);</span> <span style="color: #408080; font-style: italic">// [1, 2, 3, 4, 5, 6, 7]</span>
<span style="color: #B00040">int</span><span style="color: #666666">[]</span> c <span style="color: #666666">=</span> N<span style="color: #666666">.</span><span style="color: #7D9029">remove</span><span style="color: #666666">(</span>a<span style="color: #666666">,</span> <span style="color: #666666">7);</span>
N<span style="color: #666666">.</span><span style="color: #7D9029">println</span><span style="color: #666666">(</span>c<span style="color: #666666">);</span> <span style="color: #408080; font-style: italic">// [1, 2, 3, 4, 5, 6]</span>

b <span style="color: #666666">=</span> N<span style="color: #666666">.</span><span style="color: #7D9029">addAll</span><span style="color: #666666">(</span>a<span style="color: #666666">,</span> <span style="color: #666666">7,</span> <span style="color: #666666">8);</span>
N<span style="color: #666666">.</span><span style="color: #7D9029">println</span><span style="color: #666666">(</span>b<span style="color: #666666">);</span> <span style="color: #408080; font-style: italic">// [1, 2, 3, 4, 5, 6, 7, 8]</span>
c <span style="color: #666666">=</span> N<span style="color: #666666">.</span><span style="color: #7D9029">removeAll</span><span style="color: #666666">(</span>a<span style="color: #666666">,</span> <span style="color: #666666">7,</span> <span style="color: #666666">8);</span>
N<span style="color: #666666">.</span><span style="color: #7D9029">println</span><span style="color: #666666">(</span>c<span style="color: #666666">);</span> <span style="color: #408080; font-style: italic">// [1, 2, 3, 4, 5, 6]</span>

b <span style="color: #666666">=</span> N<span style="color: #666666">.</span><span style="color: #7D9029">insert</span><span style="color: #666666">(</span>a<span style="color: #666666">,</span> <span style="color: #666666">0,</span> <span style="color: #666666">7);</span>
N<span style="color: #666666">.</span><span style="color: #7D9029">println</span><span style="color: #666666">(</span>b<span style="color: #666666">);</span> <span style="color: #408080; font-style: italic">// [7, 1, 2, 3, 4, 5, 6]</span>
c <span style="color: #666666">=</span> N<span style="color: #666666">.</span><span style="color: #7D9029">delete</span><span style="color: #666666">(</span>b<span style="color: #666666">,</span> <span style="color: #666666">0);</span>
N<span style="color: #666666">.</span><span style="color: #7D9029">println</span><span style="color: #666666">(</span>c<span style="color: #666666">);</span> <span style="color: #408080; font-style: italic">// [1, 2, 3, 4, 5, 6]</span>

b <span style="color: #666666">=</span> N<span style="color: #666666">.</span><span style="color: #7D9029">insertAll</span><span style="color: #666666">(</span>a<span style="color: #666666">,</span> <span style="color: #666666">0,</span> <span style="color: #666666">7,</span> <span style="color: #666666">8);</span>
N<span style="color: #666666">.</span><span style="color: #7D9029">println</span><span style="color: #666666">(</span>b<span style="color: #666666">);</span> <span style="color: #408080; font-style: italic">// [7, 8, 1, 2, 3, 4, 5, 6]</span>
c <span style="color: #666666">=</span> N<span style="color: #666666">.</span><span style="color: #7D9029">deleteAll</span><span style="color: #666666">(</span>b<span style="color: #666666">,</span> <span style="color: #666666">0,</span> <span style="color: #666666">1);</span>
N<span style="color: #666666">.</span><span style="color: #7D9029">println</span><span style="color: #666666">(</span>c<span style="color: #666666">);</span> <span style="color: #408080; font-style: italic">// [1, 2, 3, 4, 5, 6]</span>

c <span style="color: #666666">=</span> N<span style="color: #666666">.</span><span style="color: #7D9029">concat</span><span style="color: #666666">(</span>a<span style="color: #666666">,</span> b<span style="color: #666666">);</span>
N<span style="color: #666666">.</span><span style="color: #7D9029">println</span><span style="color: #666666">(</span>c<span style="color: #666666">);</span> <span style="color: #408080; font-style: italic">// [1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6]</span>
N<span style="color: #666666">.</span><span style="color: #7D9029">replaceAll</span><span style="color: #666666">(</span>c<span style="color: #666666">,</span> <span style="color: #666666">1,</span> <span style="color: #666666">9);</span>
N<span style="color: #666666">.</span><span style="color: #7D9029">println</span><span style="color: #666666">(</span>c<span style="color: #666666">);</span> <span style="color: #408080; font-style: italic">// [9, 2, 3, 4, 5, 6, 7, 8, 9, 2, 3, 4, 5, 6]</span>
</pre></div>


			<p></p>
			<li><b>copy/clone/merge/erase/... Entity...</b></li>
<!-- HTML generated using hilite.me --><div style="background: #f8f8f8; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%">Account copy <span style="color: #666666">=</span> N<span style="color: #666666">.</span><span style="color: #7D9029">copy</span><span style="color: #666666">(</span>account<span style="color: #666666">);</span>
assertEquals<span style="color: #666666">(</span>account<span style="color: #666666">,</span> copy<span style="color: #666666">);</span>

N<span style="color: #666666">.</span><span style="color: #7D9029">eraseAll</span><span style="color: #666666">(</span>account<span style="color: #666666">);</span>
assertNull<span style="color: #666666">(</span>account<span style="color: #666666">.</span><span style="color: #7D9029">getFirstName</span><span style="color: #666666">());</span>
N<span style="color: #666666">.</span><span style="color: #7D9029">merge</span><span style="color: #666666">(</span>copy<span style="color: #666666">,</span> account<span style="color: #666666">);</span>
assertEquals<span style="color: #666666">(</span>account<span style="color: #666666">,</span> copy<span style="color: #666666">);</span>

Account copy2 <span style="color: #666666">=</span> N<span style="color: #666666">.</span><span style="color: #7D9029">clone</span><span style="color: #666666">(</span>account<span style="color: #666666">);</span>
assertEquals<span style="color: #666666">(</span>copy<span style="color: #666666">,</span> copy2<span style="color: #666666">);</span>

String json <span style="color: #666666">=</span> N<span style="color: #666666">.</span><span style="color: #7D9029">toJSON</span><span style="color: #666666">(</span>account<span style="color: #666666">);</span>
N<span style="color: #666666">.</span><span style="color: #7D9029">println</span><span style="color: #666666">(</span>json<span style="color: #666666">);</span>

String xml <span style="color: #666666">=</span> N<span style="color: #666666">.</span><span style="color: #7D9029">toXML</span><span style="color: #666666">(</span>account<span style="color: #666666">);</span>
N<span style="color: #666666">.</span><span style="color: #7D9029">println</span><span style="color: #666666">(</span>xml<span style="color: #666666">);</span>
</pre></div>


			<p></p>
			<li><b>Primitive Array to List/Set, List/Set to Array...</b></li>
<!-- HTML generated using hilite.me --><div style="background: #f8f8f8; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #B00040">int</span><span style="color: #666666">[]</span> a <span style="color: #666666">=</span> <span style="color: #666666">{</span> <span style="color: #666666">1,</span> <span style="color: #666666">2,</span> <span style="color: #666666">3</span> <span style="color: #666666">};</span>
IntList intList <span style="color: #666666">=</span> N<span style="color: #666666">.</span><span style="color: #7D9029">listOf</span><span style="color: #666666">(</span>a<span style="color: #666666">);</span>
N<span style="color: #666666">.</span><span style="color: #7D9029">println</span><span style="color: #666666">(</span>intList<span style="color: #666666">);</span>

List<span style="color: #666666">&lt;</span>Integer<span style="color: #666666">&gt;</span> list <span style="color: #666666">=</span> intList<span style="color: #666666">.</span><span style="color: #7D9029">toList</span><span style="color: #666666">();</span>
N<span style="color: #666666">.</span><span style="color: #7D9029">println</span><span style="color: #666666">(</span>list<span style="color: #666666">);</span>

Set<span style="color: #666666">&lt;</span>Integer<span style="color: #666666">&gt;</span> set <span style="color: #666666">=</span> intList<span style="color: #666666">.</span><span style="color: #7D9029">toSet</span><span style="color: #666666">();</span>
N<span style="color: #666666">.</span><span style="color: #7D9029">println</span><span style="color: #666666">(</span>set<span style="color: #666666">);</span>

List<span style="color: #666666">&lt;</span>Integer<span style="color: #666666">&gt;</span> list2 <span style="color: #666666">=</span> N<span style="color: #666666">.</span><span style="color: #7D9029">array2List</span><span style="color: #666666">(</span>a<span style="color: #666666">);</span>
N<span style="color: #666666">.</span><span style="color: #7D9029">println</span><span style="color: #666666">(</span>list2<span style="color: #666666">);</span>

Set<span style="color: #666666">&lt;</span>Integer<span style="color: #666666">&gt;</span> set2 <span style="color: #666666">=</span> N<span style="color: #666666">.</span><span style="color: #7D9029">array2Set</span><span style="color: #666666">(</span>a<span style="color: #666666">);</span>
N<span style="color: #666666">.</span><span style="color: #7D9029">println</span><span style="color: #666666">(</span>set2<span style="color: #666666">);</span>

<span style="color: #B00040">int</span><span style="color: #666666">[]</span> a2 <span style="color: #666666">=</span> N<span style="color: #666666">.</span><span style="color: #7D9029">collection2Array</span><span style="color: #666666">(</span><span style="color: #B00040">int</span><span style="color: #666666">[].</span><span style="color: #7D9029">class</span><span style="color: #666666">,</span> set<span style="color: #666666">);</span>
assertTrue<span style="color: #666666">(</span>N<span style="color: #666666">.</span><span style="color: #7D9029">equals</span><span style="color: #666666">(</span>a<span style="color: #666666">,</span> a2<span style="color: #666666">));</span>
</pre></div>

			<p></p>
			<li><b>sort/filter/count/groupBy with lambda in Java 8</b></li>
<!-- HTML generated using hilite.me --><div style="background: #f8f8f8; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%"><span style="color: #408080; font-style: italic">// Sort</span>
N<span style="color: #666666">.</span><span style="color: #7D9029">sort</span><span style="color: #666666">(</span>accounts<span style="color: #666666">,</span> <span style="color: #666666">(</span>a<span style="color: #666666">,</span> b<span style="color: #666666">)</span> <span style="color: #666666">-&gt;</span> a<span style="color: #666666">.</span><span style="color: #7D9029">getFirstName</span><span style="color: #666666">().</span><span style="color: #7D9029">compareTo</span><span style="color: #666666">(</span>b<span style="color: #666666">.</span><span style="color: #7D9029">getFirstName</span><span style="color: #666666">()));</span>

<span style="color: #408080; font-style: italic">// Filter</span>
Account<span style="color: #666666">[]</span> res <span style="color: #666666">=</span> N<span style="color: #666666">.</span><span style="color: #7D9029">filter</span><span style="color: #666666">(</span>accounts<span style="color: #666666">,</span> e <span style="color: #666666">-&gt;</span> e<span style="color: #666666">.</span><span style="color: #7D9029">getFirstName</span><span style="color: #666666">().</span><span style="color: #7D9029">startsWith</span><span style="color: #666666">(</span><span style="color: #BA2121">&quot;ab&quot;</span><span style="color: #666666">));</span>

<span style="color: #408080; font-style: italic">// count</span>
<span style="color: #B00040">int</span> count <span style="color: #666666">=</span> N<span style="color: #666666">.</span><span style="color: #7D9029">count</span><span style="color: #666666">(</span>accounts<span style="color: #666666">,</span> e <span style="color: #666666">-&gt;</span> e<span style="color: #666666">.</span><span style="color: #7D9029">getFirstName</span><span style="color: #666666">().</span><span style="color: #7D9029">startsWith</span><span style="color: #666666">(</span><span style="color: #BA2121">&quot;ab&quot;</span><span style="color: #666666">));</span>

<span style="color: #408080; font-style: italic">// group by first name</span>
Map<span style="color: #666666">&lt;</span>String<span style="color: #666666">,</span> List<span style="color: #666666">&lt;</span>Account<span style="color: #666666">&gt;&gt;</span> map <span style="color: #666666">=</span> N<span style="color: #666666">.</span><span style="color: #7D9029">groupBy</span><span style="color: #666666">(</span>accounts<span style="color: #666666">,</span> e <span style="color: #666666">-&gt;</span> e<span style="color: #666666">.</span><span style="color: #7D9029">getFirstName</span><span style="color: #666666">());</span>
</pre></div>

			<p></p>
			<li><b>JSON/XML...</b></li>
<!-- HTML generated using hilite.me --><div style="background: #f8f8f8; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%">Account account <span style="color: #666666">=</span> createAccount<span style="color: #666666">(</span><span style="color: #BA2121">&quot;jack&quot;</span><span style="color: #666666">,</span> <span style="color: #BA2121">&quot;ye&quot;</span><span style="color: #666666">);</span>

String json <span style="color: #666666">=</span> N<span style="color: #666666">.</span><span style="color: #7D9029">toJSON</span><span style="color: #666666">(</span>account<span style="color: #666666">);</span>
<span style="color: #408080; font-style: italic">// JSON: {&quot;id&quot;:0, &quot;gui&quot;:&quot;9aca5a17-a659-4b31-bb6d-21a978be9200&quot;, &quot;firstName&quot;:&quot;jack&quot;, &quot;lastName&quot;:&quot;ye&quot;, &quot;status&quot;:0, &quot;lastUpdateTime&quot;:1440619872576, &quot;createTime&quot;:1440619872576}</span>
Account account2 <span style="color: #666666">=</span> N<span style="color: #666666">.</span><span style="color: #7D9029">fromJSON</span><span style="color: #666666">(</span>Account<span style="color: #666666">.</span><span style="color: #7D9029">class</span><span style="color: #666666">,</span> json<span style="color: #666666">);</span>
assertEquals<span style="color: #666666">(</span>account<span style="color: #666666">,</span> account2<span style="color: #666666">);</span>

String xml <span style="color: #666666">=</span> N<span style="color: #666666">.</span><span style="color: #7D9029">toXML</span><span style="color: #666666">(</span>account<span style="color: #666666">);</span>
<span style="color: #408080; font-style: italic">// XML: &lt;account&gt;&lt;id&gt;0&lt;/id&gt;&lt;gui&gt;9aca5a17-a659-4b31-bb6d-21a978be9200&lt;/gui&gt;&lt;firstName&gt;jack&lt;/firstName&gt;&lt;lastName&gt;ye&lt;/lastName&gt;&lt;status&gt;0&lt;/status&gt;&lt;lastUpdateTime&gt;1440619872576&lt;/lastUpdateTime&gt;&lt;createTime&gt;1440619872576&lt;/createTime&gt;&lt;/account&gt;</span>
account2 <span style="color: #666666">=</span> N<span style="color: #666666">.</span><span style="color: #7D9029">fromXML</span><span style="color: #666666">(</span>Account<span style="color: #666666">.</span><span style="color: #7D9029">class</span><span style="color: #666666">,</span> xml<span style="color: #666666">);</span>
assertEquals<span style="color: #666666">(</span>account<span style="color: #666666">,</span> account2<span style="color: #666666">);</span>
</pre></div>


			<p></p>
			<li><b>more...</b></li>

		</div>

	</div>
</body>

</html>